<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<script type="text/javascript">
$(document).ready(function() {
	$.unblockUI;
    $('#button_submit').click(function(){
		var val = $("#objek_name").val();
		if(val != '' || val.length != 0)
		{
			$.blockUI({ 
				message: $('img#displayBox'),
				css: { 
		            border: 'none', 
		            padding: '15px', 
		            backgroundColor: '#000', 
		            '-webkit-border-radius': '10px', 
		            '-moz-border-radius': '10px', 
		            opacity: .5, 
		            color: '#fff' 
				}
			});
	 
	        //setTimeout($.unblockUI, 5000);
		}
    }); 
});
</script>
<img id="displayBox" src="components/com_nv/assets/images/nadi.gif" style="display:none" />
<fieldset class="adminform">
	<legend>Search</legend>
	<form action="index.php?option=com_nv&view=fb" method="post" name="adminForm" id="adminForm">
		<table class="admintable">
			<tr>
				<td class="key">Objek Wisata :</td>
				<td>
					<input name="objek_name" type="text" class="textfieldku" id="objek_name" />
					<script type="text/javascript">
						var objek_name = new LiveValidation('objek_name', { validMessage: "Thanks for the input!" });
						objek_name.add(Validate.Presence, { failureMessage: "Field can't be empty!" });
					</script>
				</td>
			</tr>
			<tr>
				<td>&nbsp;</td>	
				<td>
					<input name="submit" type="submit" value="Cari" class="buttonku" id="button_submit" />
					<input name="reset" type="reset" value="Clear!" class="buttonku" id="button_reset" /> 
					<input name="result" type="hidden" value="true" />
				</td>
			</tr>
		</table>
		
		<input type="hidden" name="option" value="com_nv" />
		<input type="hidden" name="task" value="search" />
		<input type="hidden" name="view" value="fb" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="controller" value="nv" />
		<?php echo JHTML::_( 'form.token' ); ?>
	</form>
	
<?
	if($this->result)
	{
		require_once 'appinclude.php';
		
		echo '<div class="result"><fieldset><legend>Related Results with keyword "'.trim($this->str).'" :</legend><div class="scroll">';
?>
		<table class="admintable" border="0">
<?
		/****************** MASHUP WIKI ZONE *******************/
		
		if(empty($this->fb))
		{
			$photo = "<img src='' border='1' />";
			$out = "Sorry, No Records Found!";
			echo $out;
		}//end of if
		else
		{
			$max = 5;
			$min = 0;
			foreach($this->fb as $row)
			{
				if($min == $max) break;
				$out = "";
				$desired_details = array('last_name','first_name', 'status', 'pic');
				$friends_details = $facebook->api_client->users_getInfo($row->fb_id, $desired_details);
				foreach ($friends_details as $user_details) {
					$status = $user_details['status']['message'];
					$first_name = $user_details['first_name'];
					$last_name = $user_details['last_name'];
					$pic = $user_details['pic'];
				}
				
				$photo = "<img src='$pic' border='1' />";
?>
			<tr>
				<!-- KOLOM UNTUK HASIL MASHUP FOTO -->
				<td valign="top">
					<? echo $photo; ?>
				</td>
<?
				$out .= "From : <a href='http://www.facebook.com/profile.php?id=$row->fb_id'>$first_name $last_name</a><br/>";
				//$out .= "Status : $status<br/>";
				$out .= "Name : ".$row->nama_objek."<br/>";
				$out .= "Location : ".$row->lokasi_objek."<br/>";
				$out .= "Recomendation :<br/>";
				
				$out .= "The place is ";
				$how = $row->how;
				if($how==1) $out .='Very Good';
				else if($how==2) $out .='Good';
				else if($how==3) $out .='Fair';
				else if($how==4) $out .='Bad';
				else if($how==5) $out .='Very Bad';
				
				$out .= ".<br/>\"".$row->why."\"<br/><br/>";			
		
		/*************** END OF MASHUP WIKI ZONE **************/
?>
			
				<!-- KOLOM UNTUK HASIL MASHUP REKOM -->
				<td valign="top">
					<? echo $out;?>
				</td>
			</tr>
<?
			$min++;
			}//end of foreach
		}//end of else with no records
?>
		</table>
<?
	
		echo '</div></fieldset></div>';
	}//end of if RESULT
?>		
</fieldset>